//
//  MyCutomerVc.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/5/19.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "MyCutomerVc.h"
#import "MyCustomSubVC.h"
#import "BdTV.h"
#import "config.h"
#import "AcitonBayStyleTitleView.h"
#import "FooterMenuView.h"

#import "MiddleManAddCustomerViewController.h"
#import "MiddleManAddLatentCustomerViewController.h"
#import "NSString+category.h"

@interface MyCutomerVc ()<ViewPagerDataSource,ViewPagerDelegate>

@property (nonatomic,strong) AcitonBayStyleTitleView *titleView;
@property (nonatomic,assign) Boolean isEditMode;
@property (nonatomic,weak) FooterMenuView *footerView;

@property(nonatomic,assign) Boolean isRealCutomer;
@property (nonatomic,strong)UILabel *lable1,*lable2;

@end

@implementation MyCutomerVc
@synthesize titleView,footerView,titleViewClickLisIsAdd,lable1,lable2;

- (void)viewDidLoad {
    
    [self initView];
    [super viewDidLoad];
    
}



-(void)initView{
    
    self.delegate = self;
    self.dataSource = self;
    self.isRealCutomer = YES;
    
    titleView = [AcitonBayStyleTitleView creadView];
    titleView.abackBtn.hidden = self.isHidden;
    titleView.abackBtn.enabled = !self.isHidden;
//    [titleView.aeditBtn setBackgroundImage:nil forState:UIControlStateNormal];
    [titleView.aeditBtn setImage:nil forState:UIControlStateNormal];
    titleView.aeditBtn.enabled = NO;
    
    [[titleView atitleLab]setText:@"客户管理"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithCustomView:titleView];
    
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
    
    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
        
        self.navigationController.navigationBar.tintColor = UIColorFromRGB(0xfd2e2f);
    } else {
        self.navigationController.navigationBar.barTintColor = UIColorFromRGB(0xfd2e2f);
    }

}




#pragma mark - ViewPagerDataSource
- (NSUInteger)numberOfTabsForViewPager:(ViewPagerController *)viewPager {
    return 2;
}


- (UIView *)viewPager:(ViewPagerController *)viewPager viewForTabAtIndex:(NSUInteger)index {
    
   
    UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ([UIScreen mainScreen ].applicationFrame.size.width)/2, 36)];
    lable.backgroundColor = [UIColor clearColor];
    lable.font = [UIFont systemFontOfSize:14.0];
    lable.textAlignment = NSTextAlignmentCenter;
    lable.textColor = [UIColor redColor];

    if (index==0) {
        
        lable.text = @"我的客户";
        lable1 = lable;
    }else if(index==1){
        
        lable.text = @"潜在客户";
       
        lable2 = lable;
        
    }
    
    return lable;
}


- (UIViewController *)viewPager:(ViewPagerController *)viewPager contentViewControllerForTabAtIndex:(NSUInteger)index {
    
    MyCustomSubVC *vc = [[MyCustomSubVC alloc]initWithNibName:@"MyCustomSubVC" bundle:nil];
//    NSString *state ;
    if (index== 0) {
        vc.state = CUSTOMER_TURE;
        self.state = 1;
        self.isRealCutomer = YES;
//        state = @"1";
        
        
        vc.nav = self.navigationController;
    }else if (index == 1){
        vc.state=CUSTOMER_LATENT;
        self.state = -1;
        self.isRealCutomer = NO;
        vc.nav = self.navigationController;
//        state = @"-1";
    }
    
    vc.pageVC = self;
    vc.actionTitleView = self.titleView;
    
    return vc;
}


#pragma mark - ViewPagerDelegate
- (UIColor *)viewPager:(ViewPagerController *)viewPager colorForComponent:(ViewPagerComponent)component withDefault:(UIColor *)color {
    
    switch (component) {
        case ViewPagerIndicator:
            
            return [UIColor redColor];
            break;
            
        case ViewPagerTabsView:
            return [UIColor whiteColor];
            
        default:
            break;
    }
    
    return color;
}

-(CGFloat)viewPager:(ViewPagerController *)viewPager valueForOption:(ViewPagerOption)option withDefault:(CGFloat)value{
    
    if (option==ViewPagerOptionTabWidth) {
        return ([UIScreen mainScreen ].applicationFrame.size.width)/2 ;
    }else if(option==ViewPagerOptionTabHeight){
        return 36;
    }
    return value;
}

- (void)viewPager:(ViewPagerController *)viewPager didChangeTabToIndex:(NSUInteger)index{
    
    if (index==0) {
        [lable1 setTextColor:[UIColor redColor]];
        [lable2 setTextColor:UIColorFromRGB(0x333333)];
        
    }else if (index==1){
        
        [lable1 setTextColor:UIColorFromRGB(0x333333)];
        [lable2 setTextColor:[UIColor redColor]];
       
    }
}



@end